import traceback

import sys


class C:
    def f(self):
        1/0

try:
    C().f()
except Exception as ex:
    tb_type, tb_val, exc_tb = sys.exc_info()
    for filename, linenum, funcname, source in traceback.extract_tb(exc_tb):
        print( "filename< %-23s >: linenum< %s > source< '%s' > in funcname< %s() >" % (filename, linenum, source, funcname))
